As approximately 95% of all AIDS cases can be linked to sexual transmission and/or the exchange of blood and body fluids (including intravenous drug abuse), celibacy and the the avoidance of IV drug abuse will reduce one's chance of contracting AIDS to near zero.
Other than absolute celibacy, the use of condoms with a reliable spermicide, measures to avoid the exchange of body fluids (blood, semen,etc.), and the development of stable, monogamous relationships will provide relative but not certain protection. These measures, frequently referred to as "safer sex", will reduce one's chance of infection, but they do not preclude a degree of risk! Quite plainly, the fewer the number of sexual partners, the lower your risk for AIDS becomes.
Guidelines for "safer sex" are included in this section of The AIDS Stack.